#!/bin/bash

queue_num=`curl -s -L -X \
POST 'https://yiyan.baidu.com/eb/user/wait/cnt' \
-H 'Cookie: 你的Cookie' \
| grep -oP '(?<="data":)[^,]*'`

echo '【文心一言】申请排队人数:' ${queue_num}

# Pushgateway地址
PUSHGATEWAY_URL="http://localhost:9091"
# 任务名称
JOB_NAME="yiyan"
# 实例名称
INSTANCE_NAME="count"

# 推送指标
curl -X POST -H "Content-Type: application/json" --data-binary @- ${PUSHGATEWAY_URL}/metrics/job/${JOB_NAME}/instance/${INSTANCE_NAME} <<EOF
# HELP count_yiyan_help count_yiyan_help_text
# TYPE count_yiyan gauge
count_yiyan{label_name="label_value"} ${queue_num}
EOF
